<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>类的基本知识</title>
</head>
<body>

</body>
<script type="text/javascript">
  // 创建一个Person类
  class Person {
    // 构造器函数
    constructor(name, age) {
      this.name = name;
      this.age = age;
    }

    //  方法
    speak() {
      // 该方法放在了原型链中,供实例使用
      console.log(`${this.name}, ${this.age}`)
    }
  }

  class student extends Person {
    constructor(name, age, className) {
      super(name, age);
      this.className = className;
    }

    speak() {
      console.log(`${this.name}, ${this.age}, ${this.className}`)
    }

    study() {
      console.log("努力学习")
    }
  }

  const p1 = new student("Tom", 19, "高一");
  // p1.speak();
  // p1.study();

  class Car {
    constructor(name, price) {
      this.name = name;
      this.price = price;
      this.wheel = 4;
    }

    //  类中直接可以写赋值语句，如下代码的含义是给Car的实例对象上添加一个属性 a 为 1
    a = 1;


  }

  const c1 = new Car("aa", 9);
  const c2 = new Car("bb", 10);
  console.log(c1)
  console.log(c2)


</script>
</html>